<?php
class Manage_shares extends CI_Model {

    function __construct(){
        parent::__construct();
        $fb_config = array(
            'appId'  => '264489850252668',
            'secret' => '150cc65835eb81c20faa114175539758',
            'cookie' => true,
        );
        $this->load->library('facebook', $fb_config);
    }
    function shareVideo($message,$link,$photo){
        $user = $this->facebook->getUser();
        if(!$user){
            return false;
        }
        if ($user) {
            try {
                $this->post_to_wall($message,$link,$photo);
            } catch (FacebookApiException $e) {
                $user = null;
            }
        }
        
    }
    function post_to_wall($message, $link="", $photourl="") {
        $param = array('message' => $message, 'cb' => '');
        if ($photourl != "") {
            $param["picture"] = $photourl;
        }
        if ($link != "")
            $param["link"] = $link;
        $posts = $this->fb->api('/me/feed', 'post', $param);
        return $posts;
    }
}
?>
